<template>
  <div class="app-container">
    <el-card>
      <el-form
          :model="queryParams"
          ref="queryRef"
          :inline="true"
          v-show="showSearch"
      >
        <el-form-item label="申请编号">
          <el-input
              v-model="queryParams.applyCode"
              placeholder="请输入申请编号"
              clearable
              @keyup.enter="handleQuery"
          />
        </el-form-item>

        <el-form-item label="老人姓名">
          <el-input
              v-model="queryParams.applyName"
              placeholder="请输入老人姓名"
              clearable
              @keyup.enter="handleQuery"
          />
        </el-form-item>
        <el-form-item label="验收状态">
          <el-select
              v-model="queryParams.checkAcceptStatus"
              clearable
              placeholder="请选择改造状态"
              style="width: 240px"
          >
            <el-option
                v-for="dict in acceptance_status"
                :key="dict.value"
                :label="dict.label"
                :value="dict.value"
            ></el-option>
          </el-select>
        </el-form-item>

        <el-form-item>
          <el-button type="primary" icon="Search" @click="handleQuery"
          >搜索</el-button
          >
          <el-button icon="Refresh" @click="resetQuery">重置</el-button>
        </el-form-item>
      </el-form>

      <el-row :gutter="10" class="mb8">


        <right-toolbar
            v-model:showSearch="showSearch"
            @queryTable="getList"
        ></right-toolbar>
      </el-row>

      <el-table v-loading="loading" :data="postList" stripe border max-height="500">
        <el-table-column label="申请编号" align="center" prop="applyCode"  width="200" />
        <el-table-column label="老人姓名" align="center" prop="applyName" width="100" />
        <el-table-column label="性别" align="center" width="100" >
          <template #default="scope">
        <span>
           {{sys_user_sex.find(item=>item.value==scope.row.sex)? sys_user_sex.find(item=>item.value==scope.row.sex).label:''}}

        </span>
          </template>
        </el-table-column>
        <el-table-column label="年龄" align="center" prop="age"   width="100" />
        <el-table-column label="家庭住址" align="center" prop="address"  width="500"/>

        <el-table-column label="验收状态" align="center" >
          <template #default="scope">
        <span>
           {{acceptance_status.find(item=>item.value==scope.row.checkAcceptStatus)? acceptance_status.find(item=>item.value==scope.row.checkAcceptStatus).label:''}}

        </span>
          </template>
        </el-table-column>
        <el-table-column label="验收时间" align="center" prop="checkAcceptTime" />
        <el-table-column label="验收结果" align="center" >
          <template #default="scope">
        <span :class="scope.row.checkAcceptResult=='1'? 'red':''">
           {{acceptance_result.find(item=>item.value==scope.row.checkAcceptResult)? acceptance_result.find(item=>item.value==scope.row.checkAcceptResult).label:''}}
        </span>
          </template>
        </el-table-column>
        <el-table-column
            label="操作"
            align="center"
            class-name="small-padding fixed-width" width="220">
          <template #default="scope">
            <el-button link type="primary"  @click="handInfo(scope.row,1)" v-if="scope.row.checkAcceptStatus=='0'">验收</el-button>
            <el-button link type="primary"  @click="handInfo(scope.row,2)">查看</el-button>
          </template>
        </el-table-column>
      </el-table>

      <pagination
          v-show="total > 0"
          :total="total"
          v-model:page="queryParams.page"
          v-model:limit="queryParams.limit"
          @pagination="getList"
      />
    </el-card>
    <el-dialog
        v-model="open"
        :title="title"
        append-to-body
        width="800px"
        v-if="open"
        @close="cancel"
        :close-on-click-modal="false"
    >

    </el-dialog>

    <!-- 添加或修改岗位对话框 -->
  </div>
</template>

<script setup name="checkAccept">


const { proxy } = getCurrentInstance();
import { useRouter } from 'vue-router'
const router=useRouter()
const {sys_user_sex,acceptance_status,acceptance_result} = proxy.useDict(
    "sys_user_sex",'acceptance_status',"acceptance_result"
);
import {
  getRemodelCheckAcceptList
} from "@/api/AgeAppropriate/index";


const showSearch = ref(true);
const loading = ref(true);
const postList = ref([]);
const open = ref(false);
const title = ref("新增服务项目");

const total = ref(0);

const data = reactive({
  form: {},
  queryParams: {
    page: 1,
    limit: 10,
    applyCode: undefined,
    applyName:undefined,
    checkAcceptStatus:'0'
  },
  rules: {

  },
});

const { queryParams, form, rules } = toRefs(data);

/** 提交按钮 */

function cancel() {
  open.value = false;
  reset();
}
function handInfo(data,status) {
  router.push({
    name:`checkAccept`,
    params:{
      id:data.id,
      status:status
    }
  })
}

/** 查询岗位列表 */
function getList() {
  loading.value = true;
  getRemodelCheckAcceptList(queryParams.value).then((response) => {
    postList.value = response.page.list;
    total.value = response.page.totalCount;
    loading.value = false;
  });
}
function handleQuery() {
  getList();
}
function resetQuery() {
  queryParams.value = {
    page: 1,
    limit: 10,
    applyCode: undefined,
    applyName:undefined,
    checkAcceptStatus:'0'
  };
  getList();
}



getList();
</script>
<style scoped>
.red{
  color: red;
}
</style>
